#ifndef __ANGLE_H
#define __ANGLE_H

#include "stm32h7xx_hal.h"

#define USART_DMA_RECV_LEN      (100)
#define HWT101_ADDRESS          (0x01)

#define ANGLE_ERRANGE           (stuHwtReg.angle <= stuHwtReg.angle_rang || stuHwtReg.angle >= (360 - stuHwtReg.angle_rang))
#define ANGLE_ZERO              (stuHwtReg.angle <= stuHwtReg.zero_rang || stuHwtReg.angle >= (360 - stuHwtReg.zero_rang))
#define ANGLE_RANGE             (stuHwtReg.angle <= errange)

typedef struct 
{
    uint8_t Rx_buf[128];
    uint8_t Rx_len;
    uint8_t Tx_buf[128];
    uint8_t Tx_len;
}UART_Data_t;

typedef struct
{
    uint8_t readReg;
    uint8_t readLen;
    uint8_t writeReg;
    uint8_t writeLen;
    float angle;
    uint16_t angle_rang;
    uint16_t zero_rang;
    uint16_t errange;
}HWT_Reg_t;

void HWT_USART1_Init(uint32_t baudrate);
void Hwt_Read_Reg(uint8_t reg,uint8_t length);
void Hwt_Write_Reg(uint8_t reg,int16_t data);
void Hwt_Yaw_Clear(void);
unsigned short usMBCRC16(unsigned char *pu8Buf, unsigned char u8Len);
#endif
